/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Estados;

/**
 *
 * @author Alvaro
 */
public class ePuzzle extends Estado{

    int[][] situacion;
    int tam;
    int libreX,libreY;//la posicion de la ficha libre
    int[][] solucion;

    public ePuzzle(int n){
        super();
        libreX=0;
        libreY=0;
        this.situacion =new int [n][n];
        this.solucion =new int [n][n];
        this.tam=n;
        int casilla=0;
        for (int i=0;i<this.tam;i++){
            for (int j=0;j<this.tam;j++){
                this.solucion[i][j] = casilla;
                this.situacion[i][j] = casilla;
                casilla++;
            }
        }

    }


    public ePuzzle(Estado e){
        super(e);
        ePuzzle ep=(ePuzzle) e;
        this.tam=ep.getTam();
        this.situacion=new int [tam][tam];
        this.solucion=ep.getSolucion();
        for (int i=0;i<tam;i++){
            for (int j=0;j<tam;j++){
                this.situacion[i][j]=ep.getSituacion()[i][j];
            }
        }
        this.libreX=ep.getLibreX();
        this.libreY=ep.getLibreY();
    }

    public void setLibreX(int x){
        this.libreX=x;
    }
    public void setLibreY(int y){
        this.libreY=y;
    }

    public int getLibreX(){
        return this.libreX;
    }

    public int getLibreY(){
        return this.libreY;
    }

    public int getTam(){
        return this.tam;
    }

    public boolean Iguales(Estado e1, Estado e2) {
        ePuzzle ep1=(ePuzzle) e1;
        ePuzzle ep2=(ePuzzle) e2;
        int[][] situacion1=ep1.getSituacion();
        int[][] situacion2=ep2.getSituacion();
        for (int i=0;i<ep1.getTam();i++)
            for (int j=0;j<ep1.getTam();j++){
                if(situacion1[i][j]!=situacion2[i][j]){
                    return false;
                }
            }
        return true;
    }


    public int CalculaHeuristica() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int[][] getSituacion() {
        return this.situacion;
    }

    public int[][] getSolucion(){
        return this.solucion;
    }

    @Override
    public int getHeuristica() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int setHeuristica(int h) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


}
